#ifndef SIMPLE_MUSICAL_WAV_H
#define SIMPLE_MUSICAL_WAV_H
#include "simple/support/range.hpp"
#include "simple/sdlcore/utils.hpp"
#include "utils.hpp"
#include "spec.hpp"

namespace simple::musical
{

	using byte = unsigned char;

	struct wav_deleter
	{
		void operator()(SDL_AudioSpec*) const noexcept;
	};
	using spec_ptr = sdlcore::utils::object_wrapper<SDL_AudioSpec, wav_deleter>;

	class wav_data
	{
		protected:
		spec _obtained;
		uint8_t* _data;
		uint32_t _size;
	};

	class wav : wav_data, public spec_ptr
	{
		public:

		explicit wav(const char* filename);
		wav(const byte* buffer, int size);
		const spec& obtained() const noexcept;
		support::range<const uint8_t*> buffer() const noexcept;
	};

} // namespace simple::musical

#endif /* end of include guard */
